﻿using System.Globalization;
using System.Windows.Controls;
using System.Windows.Media;

namespace ComplexAlloysVisualisation
{
    public static class Helper
    {
        public static bool TryParseDouble(this TextBox textbox, out double value)
        {
            if (double.TryParse(textbox.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
            {
                textbox.Foreground = Brushes.White;
                return true;
            }
            else
            {
                textbox.Foreground = Brushes.Red;
                return false;
            }
        }

        public static bool TryParseDouble(this string text, out double value)
        {
            return double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out value);
        }
    }
}